// @ts-ignore
import {UserCityInfo} from "db://assets/script/user-city-info";
import {UserFishInfo} from "db://assets/script/user-fish-info";
import {UserAssetInfo} from "db://assets/script/user-asset-info";
import {AssetId} from "db://assets/proto/shared/v1/props";
import Long from "long";
import {configsHelper} from "db://assets/script/configs-helper";
import {UserMixingInfo} from "db://assets/script/user-mixing-info";

class UserInfo {

    uid!: string;
    name!: string;
    avatar!: string;
    cityInfo: UserCityInfo = new UserCityInfo()
    mixInfo: UserMixingInfo = new UserMixingInfo()
    fishInfo: UserFishInfo = new UserFishInfo()
    assetInfo: UserAssetInfo = new UserAssetInfo()


    start() {
        this.cityInfo.start()
        this.fishInfo.start()
        this.assetInfo.start()
        this.mixInfo.start()
    }

    setUid(uid: string) {
        this.uid = uid;
    }

    loadUid() {
        return this.uid;
    }

    setBaseInfo(name: string, avatar: string) {
        this.name = name;
        this.avatar = avatar;
    }

    loadUserLevel(): number {
        let exp = this.assetInfo.assets[AssetId.asset_id_exp]
        if (!exp) exp = Long.fromNumber(0)
        return configsHelper.loadUserLevelByExp(exp)
    }

    /**获取鱼列表 */
    loadFirstFish() {
        return this.fishInfo.loadFirstFish()
    }


    /**获取鱼列表 */
    loadFishs() {
        return this.fishInfo.loadFishes()
    }

    /**获取鱼根据id */
    loadFishById(id: Long) {
        return this.fishInfo.loadFishById(id)
    }


}

export const userInfo = new UserInfo()